The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Support for JSON data format?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
malkovich Posted - 10/20/2014 : 04:47:24 AM
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 9.1.0G (64bit) Sr2
Operating System: Windows 7 SP1

The header of our data files is formated as an INI file. That makes it easy for us to import the values into Origin by using the INIFile functions. In the future we would like to change the data file contents to the JSON format. Does OriginC support the JSON format? Or is there an easy way to handle JSON formated files with OriginC?

Kind regards.
3   L A T E S T    R E P L I E S    (Newest First)
greg Posted - 10/20/2014 : 12:51:04 PM
Castiel seems to have "let the cat out of the bag"!
Python scripting is an Origin 2015 feature.
Castiel Posted - 10/20/2014 : 11:15:27 AM
Once I had to parse files in JSON format in Origin C. Following shows how I did it (not sure if it'll work in 64-bit Origin, mine is 32-bit XP):
void jsonreader()
{
    Object js;
    js = CreateObject("MSScriptControl.ScriptControl");
    js.Language = "JavaScript";
	
    // {"success":"1","values":[1,2,3,4,5]}
    string json = "{\"success\":\"1\",\"values\":[1,2,3,4,5]}";
	
    string strVar;
    strVar.Format("var json = %s;", json);
    js.AddCode(strVar);
    js.AddCode("function getValues(){return json.values;}");
    string s = js.Run("getValues");
    printf("%s\n", s);	// 1,2,3,4,5
	
    return;
}


According to https://originlab.jira.com/wiki/display/OB/B3+-+Origin+2015+Python+Support , you can do this instead:

>>> import json
>>> js = {"success":"1","values":[1,2,3,4,5]}
>>> js['values']
[1, 2, 3, 4, 5]


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦
cdrozdowski111 Posted - 10/20/2014 : 09:42:55 AM
Origin C doesn't currently have a native JSON parser but porting/implementing one would be an interesting side project.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000