Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create HTTP Request object
Message
From
24/12/2016 10:44:22
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01645753
Message ID:
01646023
Views:
55
>>I would worry about ".expires" and ".issued" as identifiers. Too lazy to look up if specific rules for JSON "key" naming exists, but starting with a period could create invalid property names if using eval() on JSON as some languages allow. OTOH: If you view the JSON just as a serialization of a hashmap, starting the hashmaps key with a period might not be forbidden, similar to vfp not allowing field names starting with a period, but a search field, which is indexed, can start with it.
>
>I didn't create this JSON string; this string is returned by a 3P Web API. I was mistaken thinking that an object created from the JSON string has to be a collection. Antonio explained correctly that, in this case, it is a empty object with properties. And as long as I know what (the value of property "access_token") I am looking for, I can get it. Other properties of this object are not important to me in this case.
>I will be now working on converting another JSON string into a VFP cursor and hopefully it will be more structured.

The nice thing is that now you can simply "insert into yourcursor from name ojson", provided that you matched the names and types. A word of caution: if you insert... from, the types must match; if you append blank and then gather, there's some implicit conversion - perhaps a string containing a number may be gathered as a number, datetime as date and vice versa, and a few other nice things which don't work when inserting. Don't have a list in my head, there may be other combinations which work. The other nice thing is that if for the fields where the names don't match, nothing happens. They don't get populated, but don't cause an error either.

Another remark: in cases when json string contains an array of objects (of the [{...}, {...}, ... {...}] kind), on the fox side the json parser should give you an array or collection of objects like above (class "empty", one json field - one property). I was using one that Steven Black passed to me, I guess taken from either fox wiki or wwwc, and that's what it uses (also in other direction, when parsing a cursor into json).

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform