Jump to content

Feedback on Workflow for Compacting JSON for Notecards


Love Zhaoying
 Share

You are about to reply to a thread that has been inactive for 470 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Sorry if this doesn't seem to belong here, but..here goes!

I am working on my LSL "JSON Parser" . (It is an interpreter that takes JSON as input.)

The JSON ends up in Linkset Data, but starts in a Notecard. (Prior to LSD, I was going to "cache" the Notecard data..)

In order to load Notecards efficiently, I am using the maximum Notecard line lengths of 1024.  This requires breaking each JSON string into a maximum of 1024 characters per Notecard line.

Please let me know if you have any suggestions for my JSON modify / test workflow:

1. I am using a random JSON editor - an online website, JSONEditorOnline.org (because I am lazy). 

I use this JSON editor to modify my JSON for each Test. (Add "commands", modify parameters, etc.)

2. When I am ready to test, I use the JSON editor's "compact JSON" function to remove all whitespace.

3. After removing all whitespace, I use Notepad++:

a. I copy the compacted JSON into Notepad++.

b. Use the "replace all" function to convert each line to a maximum of 1024 characters,

With the "Replace All" RegEx option: Replace "^.{1024}" with "$0\r\n".

This adds line breaks every 1024 characters.

4. Then, I paste the resulting JSON into my notecard for testing.

I tried it, and I can "convert back" the JSON in Notepad++ by removing the linefeeds (again, using "replace all").  This is convenient, because I don't have to save the "original" (pre-compacted) JSON.

Note: I don't HAVE to "compact" the JSON for each test, it would just take a lot longer to load.

Thanks,

Love

 

Link to comment
Share on other sites

Just a thought, but if this ends up being a user-facing project, you can use a (x)html website embedded in the script to ask the user to upload a file from their computer to the prim.

ETA: actually, nevermind, that method cuts the length of the file to a few hundred less than 2048 chars :/

<form enctype="multipart/form-data" method="POST" >
  <input type="file" name="fileselect"> </input>
  <input type="submit"></input>
</form>

 

Edited by Quistess Alpha
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, Quistess Alpha said:

Just a thought, but if this ends up being a user-facing project, you can use a (x)html website embedded in the script to ask the user to upload a file from their computer to the prim.

ETA: actually, nevermind, that method cuts the length of the file to a few hundred less than 2048 chars :/

<form enctype="multipart/form-data" method="POST" >
  <input type="file" name="fileselect"> </input>
  <input type="submit"></input>
</form>

 

Thanks! I forgot to follow the post and just found your reply.

  • Like 1
Link to comment
Share on other sites

1 hour ago, VenKellie said:

jsoneditoronline dot org has a web editor to compact json, just paste your json in the left panel and at the top theres a Copy > Copy Compact, then paste into the notecard.

OR can just delete lines manually.

That's the editor I use. But, since notecards only work up to 1024 characters per line, that's why I have to use a separate editor to break the compacted JSON into lines of 1024.

Link to comment
Share on other sites

17 hours ago, Love Zhaoying said:

That's the editor I use. But, since notecards only work up to 1024 characters per line, that's why I have to use a separate editor to break the compacted JSON into lines of 1024.

oh i see i see. ya best to use some kind of loop to loop through each notecard then
 

if (data == EOF) {
++Notecards;
doNextNotecard();
}

EOF is End Of File, use that in your data_server event

Link to comment
Share on other sites

Just for context, how much JSON data do you generally have to process? Are we talking about 2-4 notecard lines, or dozens?

Personally I might use my text editor throughout the whole process, to avoid copypasting from a website, since my editor has plugins to do the minifying/beautifying on its own.

What about having the minified JSON directly in the test script, so it would not have to be loaded?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 470 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...