[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternati
From: |
Philip Nienhuis |
Subject: |
[Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json |
Date: |
Wed, 28 Oct 2020 04:42:38 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0 |
Update of patch #9980 (project octave):
Status: Need Info => In Progress
_______________________________________________________
Follow-up Comment #21:
Just curious and for some more evaluation, in Octave-7.0.0 I tried fromJSON
and jsonencode on some random json file in my Firefox and Seamonkey profiles
(lots of json files there),
For example:
>> file = 'broadcast-listeners.json'
file = broadcast-listeners.json
>> fid = fopen (file);
txt = fread (fid, Inf, "*char")';
fclose (fid);
>> txt
txt =
{"version":1,"listeners":{"remote-settings/monitor_changes":{"version":"\"1603569466778\"","sourceInfo":{"moduleURI":"resource://services-settings/remote-settings.js","symbolName":"remoteSettingsBroadcastHandler"}}}}
>> fromJSON (txt)
ans =
scalar structure containing the fields:
version = 1
listeners =
scalar structure containing the fields:
remote-settings/monitor_changes =
scalar structure containing the fields:
version: 1x17 sq_string
sourceInfo: 1x1 scalar struct
>> ans.listeners.('remote-settings/monitor_changes').version
ans = \"1603569466778\"
>> jsondecode (txt)
ans =
scalar structure containing the fields:
version = 1
listeners =
scalar structure containing the fields:
remote_settings_monitor_changes =
scalar structure containing the fields:
version: 1x15 sq_string
sourceInfo: 1x1 scalar struct
>> ans.listeners.remote_settings_monitor_changes.version
ans = "1603569466778"
Clearly Octave-7.0.0's jsondecode adapts structfield names and maybe struct
field contents, I suppose for easier handling and maybe Matlab compatibility,
while fromJSON delivers them 1:1. Yet fromJSON's output string with the
escaped backslashes looks suspicious.
Again I have no idea if these results are right or wrong; opinions, anyone?
I'm inclined to think that it's a good thing that users can (also) get "raw"
data from JSON files (provided they're correct). But that's me, being used to
digging around in data files I tend to prefer to stay as close as possible to
raw data before processing them my own way.
In another json file in my seamonkey profile I got
>> file = 'sessionstore-4.json';
:
>> jsondecode (txt);
## no errors
>> fromJSON (txt);
error: regexprep: the input string is invalid UTF-8
error: called from
fromJSON at line 61 column 7
... but I suppose that's because the URL's inside can have varying encodings
(peeking in the file I saw a lot of gunk).
Octave-7.0.0's jsondecode seems more resilient.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/patch/?9980>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, (continued)
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/26
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Kai Torben Ohlhus, 2020/10/26
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Philip Nienhuis, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, John W. Eaton, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, John W. Eaton, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Philip Nienhuis, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Philip Nienhuis, 2020/10/27
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json,
Philip Nienhuis <=
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/28
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Philip Nienhuis, 2020/10/28
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/29
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/29
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Markus Mützel, 2020/10/29
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Philip Nienhuis, 2020/10/30
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/31
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, Markus Mützel, 2020/10/31
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/31
- [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json, anonymous, 2020/10/31