Author Topic: JSON Parser help  (Read 3984 times)

ganapathi

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
    • Optimal Đ¡asual Dating - Authentic Damsels
JSON Parser help
« on: October 31, 2018, 03:20:05 PM »
Hi,

Can you please help me with the JSON Parser default cpp function to utilize in modules.

Where i want to format JSON String to JSON Object and add/remove key/value on object .



« Last Edit: October 31, 2018, 03:31:48 PM by ganapathi »

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: JSON Parser help
« Reply #1 on: November 02, 2018, 01:10:16 AM »
JSON parser is implemented in libyatescript.
You may link your module with it.
Take a look at modules/javascript.cpp on usage.

ganapathi

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
    • Optimal Đ¡asual Dating - Authentic Damsels
Re: JSON Parser help
« Reply #2 on: November 02, 2018, 02:03:06 AM »
Yes. I already linked module with libyatescript and trying with javascript reference but don't know how to access it.

Code: [Select]
ObjList* stack;
GenObject* context;
ExpOperation* op = JsParser::parseJSON(text,mutex(),&stack,context);

//May be if empty then empty JSON object
if (!op)
    op = new ExpWrapper(0,"JSON");
ExpEvaluator::pushOne(stack,op);


Above one to parse and create object i think. but didn't find to access json value.

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: JSON Parser help
« Reply #3 on: November 02, 2018, 04:39:25 AM »
ExpOperation* op = JsParser::parseJSON(text);
op may be a JsArray or JsObject.
Use YOBJECT macro to check it.
I think you can use the params() method of ScriptContext to access parameters.

parseJSON() method was designed to be used in javascript.
It is not easy to use in another context.
Take a look at libs/yscript/yatescript.h: API for scripting objects.