Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create HTTP Request object
Message
From
23/12/2016 19:00:14
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01645753
Message ID:
01645995
Views:
47
>Hi,
>
>I am still having a problem. This is a question for anybody who may know the answer.
>
>Here is my sample Json-formated string:
>
>
>cJsonStr = [{"access_token":"OCu_7Rt","token_type":"bearer","expires_in":1209599,".issued":"Fri, 23 Dec 2016 21:58:29
> GMT",".expires":"Fri, 06 Jan 2017 21:58:29 GMT"}]
>
>
>When I read this string into an object, as the follows:
>
>oJson = nfjsonread( cJsonStr )
>
>Then it fails on oJson.count - Count does not exist. I wanted to loop through the elements of this object but cannot find how if the object does not have property .COUNT
>
>But I can see all the values of the oJson in the debugger with Name and Value pair. But not loop in code.
>
>What am I missing?
>
>UPDATE. I can get the value of "access_token", which is what I was looking for. The value is stored in
>oJson.access_token
>But I thought - just to understand - that I could loop through the names of this collection (if this object is indeed a collection).

I believe it's not a collection: it's an Empty object to which properties have been added.

To display the contents of the JSON object (note: I'm not taking arrays in consideration)
LOCAL ARRAY JsonMembers(1)
LOCAL LoopIndex AS Integer

FOR m.LoopIndex = 1 TO AMEMBERS(m.JsonMembers, m.oJson, 0)

	? m.JsonMembers[m.LoopIndex], "=", EVALUATE("m.oJson." + m.JsonMembers[m.LoopIndex])

ENDFOR
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform