Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, just dipping my toes into the Casablanca world and need some help working with json::value objects - I've made a call to a server which returns JSON and have the data I want in jsonValue as shown below - the element I need is "result" and I can't fathom out how to get it out of the collection - I've tried auto myres = jsonValue[3] which gives an error no operator "[]" matches these operands - any ideas ?


C#
jsonValue dump
object {size = 4}
    [0]: (L"id", 1)
    [1]: (L"method", 0x0047c694 L"slim.request")
    [2]: (L"params", array {size = 2})
    [3]: (L"result", object {size = 11})
    [Raw View]: 0x0282f0c0 {m_value=unique_ptr {m_object={size = 4} } m_kind=Object(3) }


What I have tried:

What I've tried is in the question
Posted

1 solution

C++
auto objValue=dump[_T("result")].as_object()


See Casablanc docs[^]
 
Share this answer
 
Comments
pkfox 17-Feb-16 3:33am    
Doesn't compile - I'm not using MFC here this is pure C++ - the following code did the trick

json::value jsonValue2 = jsonValue.at(U("result"));

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900