Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
JSON.parse()
This thread has 3 replies. Displaying all posts.
Post 1 made on Wednesday November 13, 2019 at 08:33
randman
Long Time Member
Joined:
Posts:
June 2003
369
Does Prontoscript support a JSON.parse()? If not, I saw another thread that mentioned this: [Link: github.com]

Or does someone have a recommendation for a good JSON.parse() that can be used with Prontoscript?
OP | Post 2 made on Wednesday November 13, 2019 at 19:06
randman
Long Time Member
Joined:
Posts:
June 2003
369
I found two ways to do what I need:

1. Use json2.js from [Link: github.com] . All I had to do was pull json2.js, put it in my Pronto Libraries folder, and add the following lines to the top of the file:

/*!
@author douglascrockford
@title json2
@version 1.1
*/

This file provides JSON.parse() and stringify.

OR

2. Just use eval. For example:

var jsonObj = eval("(" + jsonText + ")");

I suppose JSON.parse is supposed to be more secure than just using eval, although non-native JSON.parse (like in json2.js) also uses eval. I suppose JSON.parse does do other checks. My use of JSON.parse is in response to user actions, so it's not something that's called often, and from my quick testing there is no noticeable negative performance impact of using JSON.parse.
Post 3 made on Thursday November 14, 2019 at 22:48
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,340
Here's a lightweight JSON parser that does not use eval.

[Link: code.google.com]

Original Source Code
[Link: code.google.com]

Minified version
[Link: code.google.com]

I use this to create objects from JSON markup and then use JSON.stringify() to create JSON markup for transmission outside of Pronto.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 4 made on Friday November 15, 2019 at 13:52
randman
Long Time Member
Joined:
Posts:
June 2003
369
On November 14, 2019 at 22:48, Lyndel McGee said...
Here's a lightweight JSON parser that does not use eval.

[Link: code.google.com]

Original Source Code
[Link: code.google.com]

Minified version
[Link: code.google.com]

I use this to create objects from JSON markup and then use JSON.stringify() to create JSON markup for transmission outside of Pronto.

Oh, great. Thanks!


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse