Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
JSON or XML Format #261621
04/18/09 22:27
04/18/09 22:27
Joined: Apr 2009
Posts: 4
O
oversky Offline OP
Guest
oversky  Offline OP
Guest
O

Joined: Apr 2009
Posts: 4
Hi,

does someone has a little code, engine or library to load (and or) save files in JSON or XML format?

thanks!

Re: JSON or XML Format [Re: oversky] #261715
04/19/09 17:36
04/19/09 17:36
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Ralph Offline
Senior Member
Ralph  Offline
Senior Member

Joined: Feb 2006
Posts: 385
Oldenburg,Germany
What do you want to save in it?
Only text?

Re: JSON or XML Format [Re: Ralph] #261727
04/19/09 19:09
04/19/09 19:09
Joined: Apr 2009
Posts: 4
O
oversky Offline OP
Guest
oversky  Offline OP
Guest
O

Joined: Apr 2009
Posts: 4
Yes, but with highly structured data.
for example, in JSON format , properties of a character :

Code:
{
  "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 :

Code:
...
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
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

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
O
oversky Offline OP
Guest
oversky  Offline OP
Guest
O

Joined: Apr 2009
Posts: 4

Quote:

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 blush)

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
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

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
O
oversky Offline OP
Guest
oversky  Offline OP
Guest
O

Joined: Apr 2009
Posts: 4
Hi,

ok, no offense grin , 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
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

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.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1