Flexibel JSON

Flexibel JSON

nessinitsnessinits Posts: 86Questions: 27Answers: 0

Got a question,perhaps a request:

Currently the JSON structure is fixed: {"data":[],"options":[],"files":[]}
Is it possible to add parts to the current JSON structure, like this: {"data":[],"options":[],"files":[],"messages":["Notification"]}

This question has an accepted answers - jump to answer


  • allanallan Posts: 49,472Questions: 1Answers: 7,270 Site admin
    Answer ✓

    Absolutely! Are you using the PHP libraries? You can use the Editor->data() method to get the data structure and then modify it as you wish before sending it to the client-side:

    $json = new Editor( ... )
      ->fields( ... )
      ->process( $_POST )
    $json['messages'] = [];
    $json['messages'][] = 'Notification';
    echo json_encode( $json );

    The .NET and NodeJS libraries have a similar data method on the Editor class.


Sign In or Register to comment.