Question

est un objet JSON-RPC j'applique

{
         "method":"create",
         "params": [
                     {
                     "nid": "69",
                     "body": 
                                    {
                                    "und": 
                                        [
                                        {
                                        "value":
                                            "blah"
                                        }
                                        ]
                                    }   
                     }
                     ]
        }

Voici comment je le ferais avec "normal" JSON

 {
   "method":"create",
   "id":"69",
   "value":"blah"
 }

depuis JSON est un analysé comme une carte ou un dictionnaire, cela devrait être suffisant quelle que soit la présence de JSONArrays imbriqués et objets JSON dans ces tableaux, expliquer pourquoi JSON-RPC est meilleur ou désiré par quoi que ce soit

merci!

Était-ce utile?

La solution

  • Your JSON-RPC is invalid; id has to be at the top level, as it is in your "normal" JSON
  • After correcting for the above, your JSON-RPC is still needlessly complex; params could just be [{"value":"blah"}]. Which would make your "normal" JSON very slightly less complex, but harder to parse (since you couldn't rely on "params" no matter what)
  • Your "normal" JSON would not allow for unnamed parameters (ones identified solely by position). Thus, the minimal added complexity buys you something which you might not need in your application, but others might
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top