Click here to Skip to main content
15,888,802 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: So, I'm sat in the car in a hospital car park... Pin
den2k889-Dec-20 4:39
professionalden2k889-Dec-20 4:39 
GeneralRe: So, I'm sat in the car in a hospital car park... Pin
dandy729-Dec-20 5:41
dandy729-Dec-20 5:41 
GeneralRe: So, I'm sat in the car in a hospital car park... Pin
Martin ISDN12-Dec-20 12:32
Martin ISDN12-Dec-20 12:32 
GeneralWSO CCC OTD 2020-12-09 Pin
yacCarsten8-Dec-20 21:20
yacCarsten8-Dec-20 21:20 
GeneralRe: WSO CCC OTD 2020-12-09 Pin
5teveH8-Dec-20 21:39
5teveH8-Dec-20 21:39 
GeneralRe: WSO CCC OTD 2020-12-09 - Winner Pin
yacCarsten8-Dec-20 21:47
yacCarsten8-Dec-20 21:47 
GeneralRe: WSO CCC OTD 2020-12-09 - Winner Pin
5teveH9-Dec-20 0:32
5teveH9-Dec-20 0:32 
QuestionMaybe my least favorite programming task other than CRUD creation Pin
honey the codewitch8-Dec-20 16:44
mvahoney the codewitch8-Dec-20 16:44 
I have to convert a recursive traversal to an iterative one. Frown | :(

My poor ESP32 can't handle the stack my JSON reader is generating. I have an optimization for skipping entire subtrees wihout actually parsing everything therein. The problem is it calls skipObjectPart() which may call skipArrayPart() which may call skipObjectPart(). Here I thought I was already ahead because it doesn't use stack in cases like { "foo": { "bar": {} } } only on the edge conditions where you're transitioning from a nested array to a nested object and vice versa like { "foo": [ { "bar": {} } ] } but even with that optimization it takes too much stack on my test document (about 120kB of highly nested JSON data)

So now I need to figure out how to do the whole thing iteratively

I do not like having to eliminate recursion. I guess this is what I get for porting from C# code to an embedded device.

It just occurred to me that I could eliminate the recursion entirely and easily by not distinguishing between {} and []. I would expect the document to be balanced in terms of left right brackets but i could ignore what the actual brackets are. That would lead to things like accepting { foo: [} ] but I think I might be able to get away that. Consider what a bad document looks like. If it's corrupt, how likely is it to be corrupt but still balanced in terms of general left and right brackets? Do you think this is an acceptable optimization for a tiny device who is reading data that 99% of the time will be machine generated? I've seen some pretty nefarious hacks to get big data to run on small systems, and this is one such situation. I'm flexible.
Real programmers use butterflies


modified 8-Dec-20 22:55pm.

AnswerRe: Maybe my least favorite programming task other than CRUD creation Pin
Daniel Pfeffer8-Dec-20 19:32
professionalDaniel Pfeffer8-Dec-20 19:32 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
CodeWraith8-Dec-20 20:11
CodeWraith8-Dec-20 20:11 
AnswerRe: Maybe my least favorite programming task other than CRUD creation Pin
Fueled By Decaff9-Dec-20 1:09
Fueled By Decaff9-Dec-20 1:09 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
honey the codewitch9-Dec-20 1:25
mvahoney the codewitch9-Dec-20 1:25 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
Fueled By Decaff9-Dec-20 3:19
Fueled By Decaff9-Dec-20 3:19 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
jsc429-Dec-20 2:51
professionaljsc429-Dec-20 2:51 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
PIEBALDconsult9-Dec-20 3:19
mvePIEBALDconsult9-Dec-20 3:19 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
honey the codewitch9-Dec-20 3:22
mvahoney the codewitch9-Dec-20 3:22 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
PIEBALDconsult9-Dec-20 3:49
mvePIEBALDconsult9-Dec-20 3:49 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
honey the codewitch9-Dec-20 3:54
mvahoney the codewitch9-Dec-20 3:54 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
PIEBALDconsult9-Dec-20 6:47
mvePIEBALDconsult9-Dec-20 6:47 
GeneralRe: Maybe my least favorite programming task other than CRUD creation Pin
honey the codewitch9-Dec-20 6:52
mvahoney the codewitch9-Dec-20 6:52 
General/dev/null as a service PinPopular
Brisingr Aerowing8-Dec-20 15:19
professionalBrisingr Aerowing8-Dec-20 15:19 
PraiseRe: /dev/null as a service Pin
Daniel Pfeffer8-Dec-20 19:31
professionalDaniel Pfeffer8-Dec-20 19:31 
GeneralRe: /dev/null as a service Pin
Johnny J.8-Dec-20 21:03
professionalJohnny J.8-Dec-20 21:03 
GeneralRe: /dev/null as a service Pin
5teveH8-Dec-20 21:30
5teveH8-Dec-20 21:30 
GeneralRe: /dev/null as a service Pin
k50549-Dec-20 3:51
mvek50549-Dec-20 3:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.