New JSON feature: ValueAtPath

As per request I have now added a new feature to the cJSONDictionary: ValueAtPath

How to use ValueAtPath

For this example I'll be using the following JSON structure:

Parsing and fetching some values. Remember to update your cJSONDictionary.pkg to version 1.11.

Share

Some updates

Update #1
Version 1.01 of the cDictionary class is now available. It's a subclass of Microsoft's Scripting.Dictionary and it's a big speed-up compared to my cHashTable class. Unfortunately there are some limitations to what can be stored in the dictionary. The cHashTable can store any VDF type, including structs and struct arrays. The cDictionary can't. Arrays of any other type than String[] or Variant[] will also generate an error if inserted.

Avaliable methods are Set Value, Get Value, KeyExists, DeleteKey and Keys.

Update #2
Version 1.14 of cJSONParser is also available. All reduntant Ascii(c) calls have been removed. The speed gain from this was almost non-measurable, but the code looks better.

Number of milliseconds to parse a string of size x Kb.

All of the above is available on the downloads page.

Share

cJSONParser v1.13 avaliable

With some help from DAW forum user Focus I've now improved the cJSONParser class. The parsing speed is about 270% faster on average compared to v1.12.

Important!
Auto parsing Microsoft style dates are now disabled by default. The feature can be activated by setting pbAutoParseMicrosoftDates to true before calling the Parse method.

Please download the latest version of VDFWebToolkit from the Downloads section.

Share

New JSON features

edit_select_all

Due to the slight ambigousity of the cJSONDictionary I decided to add support for explicitly typed values. I've had some bad experiences with Handle and Integer collisions while serializing a cJSONDictionary to a JSON string. As a side effect this also improves the precision of the cJSONParser. Great stuff!

Download the latest VDF Web Toolkit from the downloads page.

New public method for cJSONDictionary.pkg

Procedure Set TypedValue String sKey _jsond_type type Variant vValue _jsond_type is one of the following

  • _jsond_null
  • _jsond_bool
  • _jsond_string
  • _jsond_number
  • _jsond_object
  • _jsond_array
  • _jsond_object_array

Code Example

JSON string resulted from code above

Share

JSON serialization

edit_select_all

New cJSONDictionary feature!

Those of you who read the JSON Parser article probably remember that the JSON Parser returns an instance of the cJSONDictionary class. The cJSONDictionary class is now revised and I've added a method called -Serialize. Just call the method whenever you want a string representation of your cJSONDictionary, which probably is quite often.

For code examples and a more detailed description read the full article.

Share

The JSON Parser

Nice and easy JSON parsing for VDF!

Lately I've been working on an Objective-C/Cocoa project with lots of JSON parsing. I've grown fond of working with the NSDictionary class and I figured it would be nice to have something similar for Visual Dataflex. Just simple stuff: pass a string representation of a JSON object to a parser and get a nested dictionary (cHashTable) in return. Read the full article.

Share