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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Support for JSON data format?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

malkovich

Germany
14 Posts

Posted - 10/20/2014 :  04:47:24 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

cdrozdowski111

USA
247 Posts

Posted - 10/20/2014 :  09:42:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Origin C doesn't currently have a native JSON parser but porting/implementing one would be an interesting side project.
Go to Top of Page

Castiel

343 Posts

Posted - 10/20/2014 :  11:15:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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]


妾+   午旦  妹罕妾  妾伊    用仇  妾/     岫ㄞ
 妾京用 仍巨  件 侈   件戶' 甘岫平   /欠  白岫妹
   併             艮          岫  奈 白   岫
                              岫
Go to Top of Page

greg

USA
1378 Posts

Posted - 10/20/2014 :  12:51:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Castiel seems to have "let the cat out of the bag"!
Python scripting is an Origin 2015 feature.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000