Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Nymphodora, Quad), 919 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
DataParse - support for eccentric JSON data #475919
01/13/19 21:57
01/13/19 21:57
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
jcl,

I have JSON data that looks like this. I pulled it from the Darwinex API. I was hoping to have a blog entry, where I demonstrate Zorro's ability to download and parse JSON data with nothing more than a Zorro script, but maybe I will need to make and load a DLL too.

It also does not help that it starts with an eccentric element at the beginning of the array.

Code:
{
  "candles": [
    {
      "timestamp": 1532638800
    },
    {
      "candle": {
        "close": 1045.31,
        "max": 1045.31,
        "min": 1045.31,
        "open": 1045.31
      },
      "timestamp": 1532898000
    },
    {
      "candle": {
        "close": 1038.23,
        "max": 1046.22,
        "min": 1037.03,
        "open": 1045.31
      },
      "timestamp": 1532984400
    },
    {
      "candle": {
        "close": 1025.54,
        "max": 1042.31,
        "min": 1025.54,
        "open": 1038.3
      },
      "timestamp": 1533070800
    },
// etc etc


I'm thinking that in the future, it might be helpful for dataParse to support a format such as this:

Code:
const char* format = "candles,timestamp,%t,candle->max,candle->min,candle->open,candle->close";
int numparsed = dataParse(h,format,filename);
printf("nnumparsed = %d",numparsed);



Can this go on the to-do list?

Thanks,
Andrew

Re: DataParse - support for eccentric JSON data [Re: AndrewAMD] #475922
01/14/19 05:17
01/14/19 05:17
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Have you tried dataParseJSON? It's an unusual JSON format, but it could work.

Re: DataParse - support for eccentric JSON data [Re: jcl] #475933
01/14/19 14:05
01/14/19 14:05
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online OP
Serious User
AndrewAMD  Online OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Oh, I meant to use DataParseJSON.

But... it still didn't work using this code:
Code:
int h = 1;
const char* format = "candles,timestamp,%t,max,min,open,close";
int numparsed = dataParseJSON(h,format,filename);
printf("\nnumparsed = %d",numparsed);



I attached the JSON file for your reference.

Thanks,
Andrew

Attached Files
scs_1d.zip (55 downloads)
Re: DataParse - support for eccentric JSON data [Re: AndrewAMD] #476307
02/16/19 09:36
02/16/19 09:36
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
As far as I see the data is only mildly eccentric. Candle and timestamp are stored in 2 objects, so Zorro would parse any candle twice. Remove the two extra brackets with a search-replace operation, then you can parse it. Or parse it unchanged and then remove the redundant lines with dataCompress.

void main()
{
dataParseJSON(1,"candles,timestamp,%t,max,min,open,close,,","scs_1d.json");
dataSave(1,"jsontest.t6");
}


Moderated by  Petra 

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