Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
C#/PHP read JSON string from PHP into C#
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="griimnak" data-source="post: 456459" data-attributes="member: 35695"><p>Your PHP looks really messy, just stick to this template when making your json encode array and try again:</p><p>[CODE=PHP]</p><p><?php</p><p>// {"info":{"key1":"val1","key2":"val2","key3":"val3","key4":"val4"}}</p><p>$myarray["info"] = array(</p><p> "key1"=>"val1",</p><p> "key2"=>"val2",</p><p> "key3"=>"val3",</p><p> "key4"=>"val4"</p><p>);</p><p>$myJSON = json_encode($myarray);</p><p>echo $myJSON;</p><p>?></p><p></p><p></p><p>[/CODE]</p><p>Your json object is borked as expressed by the exception you posted, [ICODE]Cannot deserialize the current JSON array (e.g. [1,2,3]) because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. [/ICODE]</p></blockquote><p></p>
[QUOTE="griimnak, post: 456459, member: 35695"] Your PHP looks really messy, just stick to this template when making your json encode array and try again: [CODE=PHP] <?php // {"info":{"key1":"val1","key2":"val2","key3":"val3","key4":"val4"}} $myarray["info"] = array( "key1"=>"val1", "key2"=>"val2", "key3"=>"val3", "key4"=>"val4" ); $myJSON = json_encode($myarray); echo $myJSON; ?> [/CODE] Your json object is borked as expressed by the exception you posted, [ICODE]Cannot deserialize the current JSON array (e.g. [1,2,3]) because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. [/ICODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
C#/PHP read JSON string from PHP into C#
Top