Skip to content

Instantly share code, notes, and snippets.

@chivalry
Last active May 11, 2017 22:24
Show Gist options
  • Save chivalry/d14f607d6e38ccaaca4d97eef69a235d to your computer and use it in GitHub Desktop.
Save chivalry/d14f607d6e38ccaaca4d97eef69a235d to your computer and use it in GitHub Desktop.
// json.Assign ( _json )
// Purpose: Assigns JSON keys to local variables with given values.
// Parameters: _json: The JSON to parse
// Version: 1.0 - Charles Ross - 17-05-11
// Example: Let (
// _ = json.assign ( JSONSetElement ( "" ; "foo" ; "bar" ; JSONString ) ) ;
// $foo = "bar"
// )
Case (
ValueCount ( JSONListKeys ( _json ; "" ) ) = 0 ;
"" ;
Let (
[
_keys = JSONListKeys ( _json ; "" ) ;
_key = GetValue ( _keys ; 1 ) ;
_value = JSONGetElement ( _json ; _key ) ;
_json = JSONDeleteElement ( _json ; _key ) ;
_calc = "Let ( $" & _key & " = " & Quote ( _value ) & " ; \"\" )" ;
_ = Evaluate ( _calc )
] ;
json.Assign ( _json )
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment