Author Topic: JSON Challenge  (Read 729 times)

Offline AIR

  • BASIC Developer
  • Posts: 504
Re: JSON Challenge
« Reply #45 on: January 05, 2019, 01:38:15 AM »
Here's a quick and dirty example using an unreleased version of JADE, along with JUTE:

Code: C++
  1. #include <jade.hpp>
  2. #include "jute.h"
  3.  
  4. MAIN
  5.     using namespace jute;
  6.     STRING str(LOADFILE$("test.json"));
  7.     jValue data = parser::parse(str);
  8.     PRINT( data["Person"]["Name"].to_string() );
  9.     PRINT( data["Person"]["Age"].to_string() );
  10.     PRINT( data["Person"]["Hobbies"][0].to_string() );
  11.     PRINT( data["Person"]["Hobbies"][1].to_string() );
  12.     PRINT( "\n", data.to_string());
  13. END
  14.  

$ jade jtest.cc jute.o -ljade -o jtest
$ ./jtest
"Homer"
39
"Eating"
"Sleeping"

{
  "Person": {
    "Name": "Homer",
    "Age": 39,
    "Hobbies": ["Eating", "Sleeping"]
  }
}

Offline John

  • Forum Support / SB Dev
  • Posts: 2340
    • ScriptBasic Open Source Project
Re: JSON Challenge
« Reply #46 on: January 05, 2019, 09:40:01 AM »
I'm glad you're still on the JADE path. The JUTE json library looks easier to use than the Parson library.

Can SB use C++ libraries to create extension modules?
« Last Edit: January 05, 2019, 12:21:29 PM by John »