Home AMX User Forum AMX General Discussion
Options

JSON marshalling

Hi,
Netlinx provides primitive functions to encode/decode variables (even structures) to plain strings sand XML strings.

I found several posts stating that some works have been made by AMX firmware engineers to provides functions for support parsing of JSON strings.

My question (rather a proposal) to AMX firmware engineers is: could you provide a function for encoding/decoding structures to JSON strings and vice-versa?I mean STRUCTURE_TO_JSON and JSON_TO_STRUCTURE

I think this could be very useful for dealing with Web Services, which nowadays are based on JSON and the REST approach.

Anyway I plan to start to experiment Caf? Duet soon: I suspect that is the right place for developing modules interacting with Web Services, exploiting Java classes for interacting with them and the conversion with JSON.

Best,
Diego

Comments

  • Options
    ajish.rajuajish.raju Posts: 185
    Hi Diego,

    How is your progress with Duet and Web Services. I am also planning to go this route.
  • Options
    PhreaKPhreaK Posts: 966
    Native JSON encode/decode would be a beautiful thing to see in NetLinx. Until then, here's a port of a fantastic C JSON parser that we've recently open sourced: https://github.com/ciasia/jsmn. That library will handle parsing of JSON data of any depth and complexity. For parsing, either iterate over tokens, or build yourself a state machine as per the example here,

    For encoding, here's a kludgy include that I use. It's pretty limited, however useful enough for building the contents of most POST requests or similar.
  • Options
    ajish.raju wrote: »
    Hi Diego,

    How is your progress with Duet and Web Services. I am also planning to go this route.

    Actually, I have to start: now I am very busy on fixing/enhancing several AMX systems coded with Netlinx...I hope to start with Duet soon...
  • Options
    PhreaK wrote: »
    Native JSON encode/decode would be a beautiful thing to see in NetLinx. Until then, here's a port of a fantastic C JSON parser that we've recently open sourced: https://github.com/ciasia/jsmn. That library will handle parsing of JSON data of any depth and complexity. For parsing, either iterate over tokens, or build yourself a state machine as per the example here,

    For encoding, here's a kludgy include that I use. It's pretty limited, however useful enough for building the contents of most POST requests or similar.

    Many, many thanks!
Sign In or Register to comment.