jsValid

Determines if a string contains conforming JSON data.

Syntax:

jsValid ( json-text )

Parameters:

(s) json-text: a string possibly representation of JSON data.

Returns:

(i) @True (1) if string is valid JSON data; @False (0) if not valid JSON data. 

JsValid examines a string to determine if the its contents are a valid text representation of JavaScript Object Notation (JSON) data conforming to a subset of the JavaScript Programming Language (Standard ECMA-262). It does not perform a full parse of the string so it is more efficient than using jsParse to determine a strings validity.

 

Json-Text

This parameter contains the text string to validate as conforming to the JSON standard specification .

  

Example:
  AddExtender('ilcjs44i.dll', 0, 'ilcjs64i.dll')
  
  ; JSON data text.
  strJson = $"{"pi":: 3.141,"happy":: true,"name":: "WIL JSON Extender",
    "nothing":: null,"answer":: {"everything":: 42},"list":: [1, 0, 2],
    "object":: {"currency":: "USD","value":: 42.99,"nested object":: {
    "value":: "bird egg"}},"value":: "Top level value"}$"
  
  Valid = jsValid(strJson)
  If Valid Then Result = 'String is valid JSON.'
  Else Result = 'Sting is not valid JSON data'
  Pause('JSON Data Test', Result)
  
See Also:

jsParse