PROIV Objects to text (JSON)

  

DEVELOPER

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for users to read and write and easy for machines to parse and generate. It is readable and easily manageable for exchanging data across various platforms.

JSON Object

An object starts with "{" and ends with "}" and within a number of string name/value pairs can reside. The name and value is separated by a ":" and if there is more than one name/value pairs then they are separated by ",". 
For example:

{"id":"1","name":"Jack","roll_no":"1111","degree":"BSCS"}

JSON Array

A JSON Array starts with "[" and ends with "]". Between them, a number of values can reside. If there are more than one value then they are separated by ",". 

For example:

[  

   {"id":"1","name":"Jack","roll_no":"1111","degree":"BSCS"},  

   {"id":"2","name":"Thomas","roll_no":"1112","degree":"BSCS"}  

]  

PROIV Objects to Text (JSON)

Using the export and import mechanisms in PROIV, you can convert objects into a textual JSON format. As PROIV does not have a name space concept, it is possible to have objects of different types with the same name with the file extension making them unique.

You can export PROIV objects as JSON and import them back at two levels:

You can use the ".par" files as an alternative method of moving PROIV source code between environments; whereas the individual object export files to store in an external version control system.

The objects that can be exported and imported are listed as follows (along with the file extension for each object type).

Note: The JSON object file is internally tagged with a version number to allow the object definition to be upgraded; if in case there is a change in structure or properties of an object, it allows objects of an older version to be upgraded when they are imported.

  PROIV Export Wrapper and Import Wrapper

The programmatic import wrapper and export wrapper functions work in the same manner as mentioned in export and import mechanisms, offering the ability to handle the additional formats: ".par" and JSON object files for export and directories containing JSON object files in the case of import.

JSON Export and Character Encodings other than UTF-8

In general, when developing PROIV applications it has been advised to use UTF-8 (PROIV Developer > Session Properties > Regional Settings > Server Code Page) as this provides the best support for varying Character Sets. However, it is acknowledged that some older applications may have been developed using other Server Code Pages. This causes an issue when attempting to transfer data into Java using the inbuilt JNI interface which is employed for all SSOs. PROIV does not know what Code Page was specified at the time in which the data was collated and therefore you must set an encoding in pro4v8.ini file - JAVA_STRING_CHARSET to control the character conversions through the JNI; alternatively, you can also set it in PROIV Dashboard > Virtual Machine > Server Side Objects.

When using the JSON Export Import feature for applications that have not be written using the UTF-8 Code Page, it is possible that characters may be corrupted.

It is recommended that if not already the case, you should look to convert your applications character encoding to UTF-8 to be secure that this or future encoding conversion issues are averted.

Comment on this topic

Topic ID: 500717