Hi there!
I released the json.hollywood, the json encoder and decoder for Hollywood today: https://github.com/JohnArcher/json.hollywood
It is based on the decode port of "json.lua" (https://github.com/rxi/json.lua) from this forum's user BeChris (thanks, mate!).
I use this library in one of my projects. I wanted to store information in json files so I took to extra step to further port the lua lib to Hollywood.
It is not extensively tested. It just works for my needs. So I would be happy if you use/test it and report issues via the github page or here.
Cheers!
json.hollywood
json.hollywood
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: json.hollywood
Good to see that there's a JSON parser for Hollywood now!
Btw, you might want to change http://www.hollywood-mal.de/ to http://www.hollywood-mal.com/ in README.md because it's in English...
Btw, you might want to change http://www.hollywood-mal.de/ to http://www.hollywood-mal.com/ in README.md because it's in English...
Re: json.hollywood
You are right, nice catch, thank you. Changed.
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
Re: json.hollywood
It looks like this JSON could be solution to my problem. I am actually still not sure what this JSON exactly is, hence I am asking about this.
What I am trying to do is to have something like this for example:
So basically I am after won scripting language that i can write as a txt file.
In this case when i enter city called "Capitol" it would use these EnemyGenerator commands to create Thieves and Orcs and also adding event possibility for Eathquake with "AddEvent"-command.
Idea being that when I read that file, I can read these into some sort of table, which could result in for example following:
Looks a lot like JSON could be the answer, but is JSON only for the values, and not for commands at all?
For when I try using JSON, as first command in my file is DisplayPicture(100, 100, "test.jpg) it already says line 1 col 1 (D) is an error.
So can JSON actually take those commands, or is it just for values or what is it?
What I am trying to do is to have something like this for example:
Code: Select all
Capitol:
EnemyGenerator("thieves", 10)
EnemyGenerator("orcs", 1)
AddEvent("earthquake", 2, 3)
In this case when i enter city called "Capitol" it would use these EnemyGenerator commands to create Thieves and Orcs and also adding event possibility for Eathquake with "AddEvent"-command.
Idea being that when I read that file, I can read these into some sort of table, which could result in for example following:
Code: Select all
script = {
[1] = { command = "EnemyGenerator", chance = 10},
[2] = { command = "EnemyGenerator", chance = 1},
[3] = { command = "AddEvent, chance = 2, power = 3}
}
For when I try using JSON, as first command in my file is DisplayPicture(100, 100, "test.jpg) it already says line 1 col 1 (D) is an error.
So can JSON actually take those commands, or is it just for values or what is it?
Re: json.hollywood
Could you please provide a small real example with the structure/table you want to convert to JSON?
What the json encoder does is taking a Hollywood table and converts it to json (and the decoder takes the json and converts it back to a table).
So, seeing your first code snipped (starting with "Capitol"), this cannot be converted to json directly, but your second snippet("script = { ...") should work.
What the json encoder does is taking a Hollywood table and converts it to json (and the decoder takes the json and converts it back to a table).
So, seeing your first code snipped (starting with "Capitol"), this cannot be converted to json directly, but your second snippet("script = { ...") should work.
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
Re: json.hollywood
Okay, then JSON in its current state is not answer to my problem. By the way, i made mistake on that table example:
But I wonder if I could get JSON to ignore the command parts from the txt file lines, and could just use them to get the values, since I could use my own system to get the commands read.
For right now problem is that if i have those commands there, it stops execution and errors.
Code: Select all
script = {
[1] = { command = "EnemyGenerator", enemytype="thieves", chance = 10},
[2] = { command = "EnemyGenerator", enemytype="orcs", chance = 1},
[3] = { command = "AddEvent, eventtype="earthquake", chance = 2, power = 3}
}
For right now problem is that if i have those commands there, it stops execution and errors.
Re: json.hollywood
Well, this is not the task of JSON or the JSON encoder/decoder. JSON is just another representation of structuring data. You have to write your own converting code to convert from your txt file format to a Hollywood table.
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: json.hollywood
Code: Select all
- New: Added JSON support; SerializeTable() and DeserializeTable() will now (de)serialize its data to/
from the JSON format by default; you can change this behaviour by specifying the optional adapter
argument; ReadTable(), WriteTable(), LoadPrefs(), and SavePrefs() will continue to use Hollywood's
proprietary table serialization data format for compatibility reasons; you can force those functions
to use JSON, however, by passing "default" in the "Adapter" table field; Hollywood's proprietary table
serializer can be accessed by passing "inbuilt" in the "Adapter" table field
Re: json.hollywood
Very nice, thanks!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc