[{"data":1,"prerenderedAt":323},["ShallowReactive",2],{"project-8606609":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":43,"post_text":45,"what":46,"said":65,"maker_in_thread":148,"shape":158,"grid":162,"attempts":278,"same_week":285,"maker_shows":35,"maker_hidden":315,"reader_version":316,"card":317},"8606609","iod","A Fast, Malloc-Free C++14 Json Parser and Encoder","title","Show HN: A Fast, Malloc-Free C++14 Json Parser and Encoder","https:\u002F\u002Fgithub.com\u002Fmatt-42\u002Fiod#a-fast-malloc-free-json-parser--encoder","github.com","matt42",1415963501,2014,98,45,278,2272,13,"notable","languages","json library","library",[24,25,26,27,28],"c++14 json parser","json encoder","malloc free","compile-time introspection","c++ serialization","curious",-0.182,{"positive":32,"neutral":33,"mixed":34,"critical":35},1,6,0,4,11,{"performance":38,"docs":40,"idea":41,"privacy":42},{"positive":34,"critical":39},3,{"positive":34,"critical":32},{"positive":32,"critical":34},{"positive":34,"critical":34},[32,34,34,32,34,34,34,34,34,34,34,34,34,34,39,34,34,34,39,44,39,34,34,32,34,34,34,39,34,34,34,34,34,34,34,34,32,34,39,39],5,null,{"problem":47,"audience":45,"pricing":45,"motivation":45,"time_to_build":45,"stack":58,"openness":64,"stage":64,"team_size":64},{"value":48,"source":49,"evidence":50},"Parsing and encoding JSON into C++ objects without building an intermediate dynamically allocated tree","maker",[51,54],{"id":52,"by":11,"text":53},"8610930","The parser does not extensively use std::string. to parse json keys, It uses an internal stringview class mirroring the json string (string_view is candidate to get into the next…",{"id":55,"by":56,"text":57},"8608703","haberman","> As of today, all json parsers rely dynamic data structures to parse and store the json objects. I'm not sure that's entirely fair. Callback-based parsers like YAJL leave the…",[59],{"value":60,"source":49,"evidence":61},"C++14",[62],{"id":63},"post","unknown",{"praise":66,"objections":76,"requests":98,"questions":103,"alternatives":115},[67],{"value":68,"source":69,"evidence":70},"Clever use of C++ metaprogramming for generating parsers","commenter",[71,72],{"id":55,"by":56,"text":57},{"id":73,"by":74,"text":75},"8608806","twic","> This makes its performances impossible to match in other languages such as C or Java that do not provide static introspection. A CHALLENGE! So, er, who's up for it? You could…",[77,88],{"value":78,"source":69,"evidence":79},"Uses std::string and vector, so it is not truly malloc-free",[80,84],{"id":81,"by":82,"text":83},"8609058","jlarocco","This uses std::string all over the place, which allocates memory under the hood. I'm not sure how any JSON parser could avoid memory allocation without a difficult to use…",{"id":85,"by":86,"text":87},"8609142","Iftheshoefits","It also uses vector, which is almost certainly using malloc and\u002For placement new even if the SIO somehow really does reserve space for a single object. Its also using the heap…",{"value":89,"source":69,"evidence":90},"Hand-written callback parsers like vurtun's may be faster",[91,95],{"id":92,"by":93,"text":94},"8609825","huhtenberg","On one hand this is undoubtedly a very clever use of ++ features. On the other hand that heck of a lot of scaffolding (just look in \u002Fiod directory) and the more scaffolding there…",{"id":96,"by":93,"text":97},"8611428","No, I meant of course that vurtun + all the callbacks are going to be at least as fast as iod. You'd basically pass a bit of context to every callback, so that the app would know…",[99],{"value":100,"source":69,"evidence":101},"Better documentation of the concepts",[102],{"id":55,"by":56,"text":57},[104,108],{"value":105,"source":69,"evidence":106},"How does the compile-time object introspection and codegen work?",[107],{"id":55,"by":56,"text":57},{"value":109,"source":69,"evidence":110},"Does malloc-free mean stack allocation with security risks?",[111],{"id":112,"by":113,"text":114},"8608569","rurban","Sorry, didn't read the code yet. But malloc free means stack allocation, thus dangerous to stack attacks. Please clarify.",[116,123,130,137,144],{"value":117,"source":69,"evidence":118},"jsmn",[119],{"id":120,"by":121,"text":122},"8609081","pjungwir","jsmn is a nice JSON tokenizer. You malloc a chunk of memory up front, but that's it. It gives you pointers to the tokens and you can do what you like with them. I am using it in…",{"value":124,"source":69,"evidence":125},"vurtun\u002Fjson",[126],{"id":127,"by":128,"text":129},"8609236","areop","I wrote a JSON-Parser in C with minimal validation in ~250 LOC that does not allocate memory, but leaves the type check and conversion to the user. https:\u002F\u002Fgithub.com\u002Fvurtun\u002Fjson",{"value":131,"source":69,"evidence":132},"sajson",[133],{"id":134,"by":135,"text":136},"8609286","chadaustin","sajson allocates once: it turns out you can structure your parse tree such that each byte of input only requires one machine word of output.…",{"value":138,"source":69,"evidence":139},"RapidJSON",[140],{"id":141,"by":142,"text":143},"8608836","nly","RapidJSON claims to support \"in-situ parsing\", which is presumably mostly zero copy, and presumably doesn't allocate much either. I'd like to see benchmarks over comparable code.",{"value":145,"source":69,"evidence":146},"YAJL",[147],{"id":55,"by":56,"text":57},{"comments":44,"answered":149,"key":150},2,[151,152,155],{"id":52,"text":53},{"id":153,"text":154},"8610944","The introspection comes from the SIO's of the iod library, they are novel types of object offering introspection at compile time. The iod library makes iterating on the members…",{"id":156,"text":157},"8610957","Vurtun's code is probabely faster than the iod json parser since it leaves the type check and conversion to the user. Since iod knows the structure of the object you are parsing,…",{"commenters":159,"max_depth":33,"maker_replies":44,"first_comment_mins":160,"lifespan_hours":161},32,425,25,[163,165,167,170,171,175,178,179,182,185,188,191,194,196,199,202,206,208,209,212,214,218,220,223,226,228,229,231,232,234,237,238,241,244,246,249,252,254,258,260,262,266,269,272,275],[81,34,32,164,82,34],"project\u002Fcritical\u002Fperformance",[120,34,34,166,121,34],"commenter\u002Fneutral\u002Fnone",[168,34,34,166,169,34],"8609299","aktau",[85,34,32,164,86,34],[172,34,34,173,174,34],"8609151","other\u002Fneutral\u002Fnone","codehero",[176,34,34,173,177,34],"8609213","jly",[127,34,34,173,128,34],[180,34,34,181,93,34],"8609758","other\u002Fpositive\u002Fnone",[183,34,34,173,184,34],"8610267","klibertp",[186,34,34,173,187,34],"8610282","dietrichepp",[189,34,34,173,190,34],"8610545","techdragon",[192,34,34,173,193,34],"8610836","cjcole",[195,34,34,173,174,34],"8610619",[197,34,34,173,198,34],"8610274","rxi",[200,34,34,201,128,34],"8611479","other\u002Fneutral\u002Fdocs",[203,34,39,204,205,34],"8610831","project\u002Fneutral\u002Fdocs","jeremie",[207,34,34,201,128,34],"8611484",[134,34,34,173,135,34],[210,34,34,173,211,34],"8609939","makomk",[52,34,34,213,11,32],"maker\u002Fneutral\u002Fnone",[215,34,39,216,217,34],"8610981","project\u002Fneutral\u002Fperformance","gurkendoktor",[55,32,44,219,56,34],"project\u002Fpositive\u002Fidea",[221,32,39,222,142,34],"8608866","project\u002Fneutral\u002Fidea",[224,32,34,173,225,34],"8610536","aboodman",[153,32,34,227,11,32],"maker\u002Fneutral\u002Fidea",[92,149,32,164,93,34],[156,149,34,230,11,32],"commenter\u002Fneutral\u002Fperformance",[96,149,34,230,93,34],[233,149,34,227,11,32],"8611002",[235,39,34,173,236,34],"8609047","densh",[73,35,39,222,74,34],[239,35,34,173,240,34],"8609009","madbiz",[242,35,34,173,243,34],"8609466","astral303",[141,44,34,245,142,34],"other\u002Fneutral\u002Fperformance",[247,44,34,173,248,34],"8609195","masklinn",[250,33,34,173,251,34],"8610247","dvt",[253,33,34,173,251,34],"8610543",[255,256,34,173,257,34],"8608592",7,"rdtsc",[259,256,34,173,86,34],"8608615",[261,256,34,173,257,34],"8609038",[263,256,32,264,265,34],"8608655","project\u002Fcritical\u002Fdocs","cremno",[267,256,34,268,11,32],"8610977","maker\u002Fneutral\u002Fdocs",[112,270,39,271,113,34],8,"project\u002Fneutral\u002Fprivacy",[273,270,34,166,274,34],"8608658","BinaryIdiot",[276,270,39,216,277,34],"8608689","k4st",[279,284],{"id":280,"t":281,"points":282,"comments":283},"7709815",1399466923,70,34,{"id":4,"t":12,"points":14,"comments":15},[286,291,295,300,305,310],{"id":287,"name":288,"points":289,"category":290},"8608358","Explained Visually",353,"learning_science",{"id":292,"name":293,"points":294,"category":20},"8631158","LanguageExt",164,{"id":296,"name":297,"points":298,"category":299},"8616738","pyspider",159,"dev_tools",{"id":301,"name":302,"points":303,"category":304},"8615416","SineRider",137,"games",{"id":306,"name":307,"points":308,"category":309},"8631223","Picky Pint",134,"consumer_social",{"id":311,"name":312,"points":313,"category":314},"8623864","WikiWash",131,"productivity",false,"v2",{"id":318,"name":5,"line":6,"ai":315,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":319,"top":18,"kw":320,"maker":11,"domain":10,"tier":19,"attempts":149,"strip":321,"url":9,"mix":322,"praise":68,"objection":78,"sub":21},8606609,-0.18,[24,25,26,27,28],"1001000000000030003530010003000000001033",[32,33,34,35],1794036525059]