Code: Select all
? jsonItem("17.1.1").value ' "17.1, datatype jsonNumber
But I agree with your reasoning. They are "parsable" but not single numbers.
Code: Select all
? jsonItem("17.1.1").value ' "17.1, datatype jsonNumber
https://tools.ietf.org/html/rfc8259#section-6
The representation of numbers is similar to that used in most
programming languages. A number is represented in base 10 using
decimal digits. It contains an integer component that may be
prefixed with an optional minus sign, which may be followed by a
fraction part and/or an exponent part. Leading zeros are not
allowed.
A fraction part is a decimal point followed by one or more digits.
An exponent part begins with the letter E in uppercase or lowercase,
which may be followed by a plus or minus sign. The E and optional
sign are followed by one or more digits.
Code: Select all
#include "fbjson.bas"
dim events as jsonitem
dim event as jsonitem
dim json as string
dim i as integer
open "meetup1.json" for input as #1
line input #1, json
close #1
print "raw data:"
print mid(json,1,50);"..."
print "---------"
events.parse(json)
print events.count; " events found"
for i = 0 to events.count -1
event = events[i]
print "EVENT (";i;")"
print event.tostring
print "============"
next
Code: Select all
[{"created":1558483584000,"duration":19800000,"id":"261658924","name":"O u2019 WE GO PADDLE the OSWEGO JUNE 4","rsvp_limit":12,"date_in_series_pattern":false,"status":"upcoming","time":1570370400000,"local_date":"2019-10-06","local_time":"10:00","rsvp_open_offset":"PT495H","rsvp_close_offset":"PT13H","updated":1558492693000,"utc_offset":-14400000,"waitlist_count":0,"yes_rsvp_count":1,"venue":{"id":17727712,"name":"Oswego Lake Parking","lat":0.0,"lon":0.0,"repinned":true,"address_1":"lake oswego rd and sooy rd","city":"washington","country":"us","localized_country_name":"USA","zip":"","state":"NJ"},"group":{"created":1318600152000,"name":"Outdoor Club of South Jersey Canoeing","id":2647602,"join_mode":"approval","lat":39.95000076293945,"lon":-74.91999816894531,"urlname":"Outdoor-Club-of-South-Jersey-Canoeing","who":"Members","localized_location":"Mount Laurel, NJ","state":"NJ","country":"us","region":"en_US","timezone":"US/Eastern"},"link":"https://www.meetup.com/Outdoor-Club-of-South-Jersey-Canoeing/events/261658924/","description":"<p>O u2019 WE GO PADDLE the OSWEGO.We meet at Oswego Lake Put-In. Pack Lunch. Volunteer shuttle Call or email to confirm participation Leader: </p> ","how_to_find_us":"To get to the meeting spot turn down Lake Oswego Road from Rt 563 .3152 Green Bank Chatsworth Rd Chatsworth, NJ 08019 39.704050, -74.527237","visibility":"public"}]
Code: Select all
#define fbJSON_debug
#include "fbJson.bas"
Code: Select all
fbJSON Error: Invalid number '0' encountered at position 449 one line 1.
fbJSON Error: Expected key at position 455 on line 1, found ":" instead.
Code: Select all
#define fbJSON_debug
#include once "fbJson.bas"
dim as string item1Str = !"{\"system\":{\"set_relay_state\":{\"state\":1}}}"
print item1Str
dim as jsonItem item1 = jsonItem(item1Str)
print item1.toString()
dim as string item2Str = !"{\"time\":{\"get_time\":{\"year\":2000,\"month\":1,\"mday\":2,\"hour\":2,\"min\":53,\"sec\":13,\"err_code\":0}}}"
print item2Str
dim as jsonItem item2 = jsonItem(item2Str)
print item2.toString()
print "item2[0].Key = "; item2[0].Key
print "item2[0].Value = "; item2[0].Value
print !"item2[\"month\"].Key = "; item2["month"].Key
print !"item2[\"month\"].Value = "; item2["month"].Value
Code: Select all
{"system":{"set_relay_state":{"state":1}}}
{
"system" : {
"set_relay_state" : {
"state" :
},
"state" :
}
}
{"time":{"get_time":{"year":2000,"month":1,"mday":2,"hour":2,"min":53,"sec":13,"err_code":0}}}
{
"time" : {
"get_time" : {
"year" : 2000,
"month" : 1,
"mday" : 2,
"hour" : 2,
"min" : 53,
"sec" : 13,
"err_code" :
},
"err_code" :
}
}
item2[0].Key = time
item2[0].Value =
item2["month"].Key = fbJSON Error: Key '' not found in object