|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: JSON or XML Format
[Re: Ralph]
#261727
04/19/09 19:09
04/19/09 19:09
|
Joined: Apr 2009
Posts: 4
oversky
OP
Guest
|
OP
Guest
Joined: Apr 2009
Posts: 4
|
Yes, but with highly structured data. for example, in JSON format , properties of a character : {
"id":10,
"firstname":"John",
"lastname":"Doe",
"skills":{
"life":100,
"strength":80,
"magic":75
},
"position":{
"x":120,
"y":200,
"z":150
},
"weapons":[{
"id":"weapon1",
"type":"gun",
"automatic":true
},{
"id":"weapon2",
"type":"sword"
}],
etc.....
}I gave character properties as an example, i want to use a json format for game levels characteristics. A JSON parser would load the file content in memory and would put datas in Vectors for example. then, you can simply call propertie with a syntax near like this : ...
myCharacter = JSONParseFile("filename.json");
x = myCharacter.position.x;
...I'm now trying to get JSON parser coded in C or C++ and try to rewritten them in Lite-C, or find a DLL that can be called within a Lite-C code, but ... really not simple! Any idea ?
|
|
|
Re: JSON or XML Format
[Re: oversky]
#261731
04/19/09 19:22
04/19/09 19:22
|
Joined: Aug 2005
Posts: 1,230
MichaelGale
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,230
|
Go to www.json.org, there is a list of parsers written in C at the bottom. You should be able to include them in your project without having to rewrite them. The ones written in C++ may work with some modifications. However, you will not be able to use any of these parsers like you did in your example as structures in C/C++ cannot be changed at runtime. The code to access the data will only be similar. For xml parsers, go to google and search for "xml parser c" to find appropriate parsers.
Your friendly mod is at your service.
|
|
|
Re: JSON or XML Format
[Re: MichaelGale]
#261734
04/19/09 19:46
04/19/09 19:46
|
Joined: Apr 2009
Posts: 4
oversky
OP
Guest
|
OP
Guest
Joined: Apr 2009
Posts: 4
|
Go to www.json.org, there is a list of parsers written in C at the bottom thanks, but i already know that, and i tried to implement those parser coded in C in my Lite-C code, but didn't work (not enough skills  ) concerning structures, there must be a trick to have a simple syntax to access values in a kind of array or vector variable ?
|
|
|
Re: JSON or XML Format
[Re: oversky]
#261744
04/19/09 21:01
04/19/09 21:01
|
Joined: Aug 2005
Posts: 1,230
MichaelGale
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,230
|
Well, no offence but if you are unable to implement an existing parser than you won't find it easier to write one yourself if you planned on doing so.
I only mentioned that you could not use structures in that way in case you were looking for a parser that enables you to do so.
Your friendly mod is at your service.
|
|
|
Re: JSON or XML Format
[Re: MichaelGale]
#261755
04/19/09 22:01
04/19/09 22:01
|
Joined: Apr 2009
Posts: 4
oversky
OP
Guest
|
OP
Guest
Joined: Apr 2009
Posts: 4
|
Hi, ok, no offense  , but you didn't understand me. I'm not trying to rewrite from scratch a JSON or XML parser. I tried every C parser mentionned in JSON.org web site, but I assures you that they need to be rewritten to fetch with lite-c requirements. several techniques used as enums, unions, etc... that lite-c does not understand. And, i'm trying also to compile a DLL file that is able to parse those dataexchange files for me, and simply call the result in my lite-c program. (LibExpat for XML seems to work) ...
|
|
|
Re: JSON or XML Format
[Re: oversky]
#261761
04/19/09 23:10
04/19/09 23:10
|
Joined: Aug 2005
Posts: 1,230
MichaelGale
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,230
|
Ah I see what you mean. Sorry I didn't check the sources before. I guess compiling a DLL is the best way to go then.
Your friendly mod is at your service.
|
|
|
|