How to turn this json into array

2

I need to transform this json (not all fields_atributes fields) into an array in php so I can change the data easily

    mutation{
  createCard(
    input: {
      pipe_id: 219739
      fields_attributes: [
        {field_id: "assignee", field_value:[00000, 00001]}
        {field_id: "checklist_vertical", field_value: ["a", "b"]}
        {field_id: "checklist_horizontal", field_value: ["b"]}
        {field_id: "cpf", field_value: "123.456.789-00"}
        {field_id: "cnpj", field_value: "12.345.678/1234-00"}
        {field_id: "date", field_value: "1977-01-20"}
        {field_id: "date_time", field_value: "2017-07-20T21:00:00+00:00"}
        {field_id: "due_date", field_value: "2017-07-20T21:00:00+00:00"}
        {field_id: "currency", field_value: "9500.50"}
        {field_id: "label_select", field_value: [890073, 908006]}
        {field_id: "email", field_value: "[email protected]"}
        {field_id: "number", field_value: 9000}
        {field_id: "short_text", field_value: "Rocky Balboa"}
        {field_id: "long_text", field_value: "It ain’t about how hard you hit. It’s about how hard you can get hit and keep moving forward. It’s how much you can take, and keep moving forward. That’s how winning is done."}
        {field_id: "radio_vertical", field_value: "yes"}
        {field_id: "radio_horizontal", field_value: "no"}
        {field_id: "phone", field_value: "+55 11 1234-5678"}
        {field_id: "select", field_value: "B. Rocky Balboa II"}
        {field_id: "time", field_value: "17:25"}
      ]
      parent_ids: ["2750027"]
    }
  ) {
    card {
      id
      title
    }
  }
}

But how to do it when it is like this:

        {field_id: "cpf", field_value: "123.456.789-00"}

What I've done so far is this:

$arr = array(
         "mutation" => array(
           "createCard" =>  array(
             "input" => array(
               "pipe_id" => "219739",
               "fields_attributes" => array(
                 "field_id" => "valore",
             ),
           ),
         ),
       ),

 );

If someone has doubts about JSON, it comes from the following API: pipefy

    
asked by anonymous 02.04.2018 / 16:09

1 answer

3
This is not a JSON but the format of a "request" that should be used to create a card:

  

Create card Mutation to create a card, in case of success a query is   returned   Request Body

In the documentation already says: Request Body (translating: Request, request, etc.)

Using the parameters to create a card:

In this way, you use the createCard method to insert these parameters (as in the past documentation ):

createCard(input: {params})

The return of this request , now it will be JSON :

{
  "data": {
    "createCard": {
      "card": {
        "id": "2762646",
        "title": "Rocky Balboa"
      }
    }
  }
}

To turn the return into array :

$json = // retorno da criação do card

$json_array = json_decode($json, true);

Documentation : json_decode

To see the request and return example of the "createCard" method, click the button below the example of the link you posted (or here ).

    
02.04.2018 / 17:34