View Single Post
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 05-11-2012 , 12:28   Re: [EXTENSION] SMJansson 2.3.1/1 (2012-05-07)
Reply With Quote #3

Converting JSON to KeyValues

This is a lossy conversion as KeyValues don't support arrays as JSON does and therefore this example sets the index of the value as the key in the resulting KeyValues structure.
CODE

Converting KeyValues to JSON
CODE



Using json_pack to create JSON

Pack String Rules
  • n Output a JSON null value. No argument is consumed.
  • s Output a JSON string, consuming one argument.
  • b Output a JSON bool value, consuming one argument.
  • i Output a JSON integer value, consuming one argument.
  • f Output a JSON real value, consuming one argument.
  • r Output a JSON real value, consuming one argument.
  • [<packstring>]
    • Build an array with contents from the inner format string.
    • Recursive value building is supported.
    • No argument is consumed.
  • {<packstring>}
    • Build an array with contents from the inner format string.
    • The first, third, etc. format character represent a key, and must be s (as object keys are always strings).
    • The second, fourth, etc. format character represent a value.
    • Recursive value building is supported.
    • No argument is consumed.
Examples
__________________
einmal mit profis arbeiten. einmal.

Last edited by Thrawn2; 06-24-2012 at 11:50.
Thrawn2 is offline