It is currently Wed Aug 21, 2019 3:48 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ParseJSON fail when CreateJSON with #PB_Any
PostPosted: Wed Jul 03, 2019 7:37 pm 
Offline
User
User

Joined: Thu Mar 14, 2013 11:24 am
Posts: 23
Location: paris
hello,

Code:
Define json.i = CreateJSON(#PB_Any)
Define datas$ = "[1, 2, 3, 4, 5]" 
ParseJSON(json, datas$)


give me this error:
[ERROR]#JSON object number is very high (over 10000), are you sure of that?

and stop the compilation


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseJSON fail when CreateJSON with #PB_Any
PostPosted: Wed Jul 03, 2019 8:34 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1643
Hello! Maybe the documentation should be more clear about this:

You shouldn't CreateJSON() and then pass that ID into ParseJSON()... ParseJSON() automatically creates a new JSON.
Code:
Define datas$ = "[1, 2, 3, 4, 5]"
Define json.i = ParseJSON(#PB_Any, datas$)



You might already know this stuff:

This is how most PB objects work: You either create it with an index (a literal number like 0, or a constant, or a variable, etc.) OR you use the special value #PB_Any which dynamically creates a (high-value) ID.

If you pass in an index, say 10, PB allocates JSONs 0-10 for fast indexing.

That's why it warns you, if you generate a high-value #PB_Any ID (say... 500,000) then pass that ID in again, you're going to allocate JSONs 0-500,000 in memory... you probably don't want to do that!

_________________
On GitHub: PB Includes - IDE Tools - Color Themes


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseJSON fail when CreateJSON with #PB_Any
PostPosted: Thu Jul 04, 2019 10:37 am 
Offline
User
User

Joined: Thu Mar 14, 2013 11:24 am
Posts: 23
Location: paris
It's not a compilation warning, it's a compilation error!!

But for sure I misread the documentation!!!
Sorry for the noise and thanks kenmo!

Ben


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseJSON fail when CreateJSON with #PB_Any
PostPosted: Thu Jul 04, 2019 10:49 am 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1019
Location: right here
benmalartre wrote:
It's not a compilation warning, it's a compilation error!!

Neither. It's actually a runtime error. Disable the debugger and you won't get an error.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: A.D., Sirius-2337 and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye