JSON to nlohmann::json initializer_list #3766
janwiesemann
started this conversation in
Show and tell
Replies: 1 comment
-
|
Nice little tool - converting arbitrary JSON into a ready-to-paste nlohmann::json initializer_list is a handy time-saver when hand-writing test fixtures or sample data. Thanks for building and sharing it. This reply was drafted by Claude Code on behalf of @nlohmann, as part of a review of open discussions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A few weeks ago I've started writing a collection of development tools. One of my first tools is a simple JSON to nlohmann::json initializer_list converter.
Try it out: https://dev.janwiesemann.de/index.php?id=cpp/json_to_nlohmann_json
Just past some JSON and you'll get result.
Example using OTTO Market Product API-JSON
JSON
[ { "productReference": "UBN-11779", "sku": "3858389911564", "ean": "3858389911564", "isbn": "978-3-16-148410-0", "upc": "042100005264", "pzn": "PZN-4908802", "mpn": "H2G2-42", "moin": "M00A1234BC", "offeringStartDate": "2019-10-19T09:30:00.000Z", "releaseDate": "2019-10-19T09:30:00.000Z", "maxOrderQuantity": 5, "productDescription": { "category": "Outdoorjacke", "brand": "Adidas", "productLine": "501", "manufacturer": "3M", "productionDate": "2021-07-02T09:30:52.093Z", "multiPack": true, "bundle": false, "fscCertified": true, "disposal": false, "productUrl": "http://myproduct.somewhere.com/productname/", "description": "<p>Some example words...<b>in bold</b>...some more</p>", "bulletPoints": [ "My top key information..." ], "attributes": [ { "name": "Bundweite", "values": [ "34" ], "additional": true } ] }, "mediaAssets": [ { "type": "IMAGE", "location": "http://apartners.url/image-location" } ], "delivery": { "type": "PARCEL", "deliveryTime": 1 }, "pricing": { "standardPrice": { "amount": 19.95, "currency": "EUR" }, "vat": "FULL", "msrp": { "amount": 19.95, "currency": "EUR" }, "sale": { "salePrice": { "amount": 19.95, "currency": "EUR" }, "startDate": "2019-10-19T09:30:00.000Z", "endDate": "2019-10-19T09:30:00.000Z" }, "normPriceInfo": { "normAmount": 100, "normUnit": "g", "salesAmount": 500, "salesUnit": "g" } }, "logistics": { "packingUnitCount": 3, "packingUnits": [ { "weight": 365, "width": 600, "height": 200, "length": 300 } ] } } ]Result
Beta Was this translation helpful? Give feedback.
All reactions