Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with string parsing into array
Message
 
To
07/03/2017 08:20:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01647020
Message ID:
01648824
Views:
55
>>>Hi Jaime,
>>>
>>>your string is not valid Json; a Json array is defined by open/close brackets.
>>>just put your string inside open/close brackets and you'll get the expected result: an object with an array of objects.
>>>
>>>Just try:
>>>oo = nfJsonRead(' [ {"ID": "0050", "Action": "Welding"},{"ID": "0040", "Action": "Bending"},{"ID": "0020", "Action": "Laser"} ]' )
>>>( see attached image ).
>>>
>>>correct me if I'm wrong, but unless I'm missing something, qdfoxJson 1.8 will return an object with a collection, not an array for the above sample.
>>
>>Forgot to thank you Marco. In the end, the string i had was simple enough to be parsed through a GetWordNum() loop...
>
>If you can use GetWordNum() in a loop, you can use ALines() and it'll be much faster.
>
>Tamar

For the case...
xx='{"ID": "0050", "Action": "Welding"},{"ID": "0040", "Action": "Bending"},{"ID": "0020", "Action": "Laser"}'

yy=STRTRAN(xx,": ",CHR(13))
yy=STRTRAN(yy,", ",CHR(13))
yy=STRTRAN(yy,"},{",CHR(13))
yy=chrtran(yy,'{}"',"")
licnt=ALINES(ladata,yy)
DIMENSION ladata(licnt/2,2)

CLEAR
DISPLAY MEMORY LIKE laData
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform