I'm really at my wit's end here... I'm using VB-JSON Parser (http://www.ediy.co.nz/vbjson-json-parser-library-in-vb6-xidc55680.html) and I have the following array :
[{"timestamp":1410001952,"tid":2834225,"price":"483.77"}]
The documentation is really minimal and I have no clue whatsoever of how to access the array, been searching for several hours now on how to resolve this.
How can I get the "price" value? I know that i can use .item("price") when there is no array but I don't know what to do when there's an array and there is no name before it.
First have a look at Parsing JSON in Excel VBA
It explains the JScript way of parsing JSON string.
Browsing through the net, I found it really hard to get a complete VBA based JSON parser.
Some options are available in the VB version and then there are few online parsers who promise to parse JSON and convert them in Excel. These ones work fine with simple JSON data structure. But once you feed in a complex data set with nested arrays and structures, they simply fail.
Using JavaScript features of parsing JSON, on top of ScriptControl, we can create a parser in VBA which will list each and every data point inside the JSON. No matter how nested or complex the data structure is, as long as we provide a valid JSON, this parser will return a complete tree structure.
JavaScript’s Eval, getKeys and getProperty methods provide building blocks for validating and reading JSON.
Coupled with a recursive function in VBA we can iterate through all the keys (up to nth level) in a JSON string. Then using a Tree control (used in this article) or a dictionary or even on a simple worksheet, we can arrange the JSON data as required.
Here, you can find a complete VBA example.
There is a JSON serializer in .NET: http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json
Related
Sorry for the inappropriate question. But what do you recommend me to use to structure a library that can put a query arrangement on json formats generated by an XML parsing based on TEI p5? I tried to use GraphQL by converting the interfaces of my Angular application related to parsing information from XML to JSON in type to define a GraphQL schema but I don't think that's the way.
What I have to do is query, client only, some data encoded in XML (also wanting already parsed in JSON) and, for example, search for all occurrences of a specific data.
Do you have any roadmaps to recommend or some JSON query system that might be right for me?
You might take a look at https://www.npmjs.com/package/saxon-js. With SaxonJS you're able to run XPath expression against XML using JavaScript.
I am working with a much larger JSON file than I am used too and I am getting confused on how to parse the file to extract an object.
resultJSON['BACSDocument']['Data'][0]['ARUDD'][0]['Advice'][0]['OriginatingAccountRecords'][0]['OriginatingAccountRecord'][0]['ReturnedDebitItem']
This is what I used to extract the "ReturnedDebitItem" array. I cannot use this as the json will come in different schemas but will always contain a "ReturnedDebitItem" so I need to parse the document.
I have tried using a couple of for loops but I am just receiving errors - any insight would be much appreciated. I am working with node but any pseudo code would also be helpful!
So there is a nice library for VB6 JSON parsing. HERE
but i actually used one that built on the original and optimized. HERE
Essentially I'm using the parser to deserialize the json i get from a web service. I need to update some values, and resend to the server. Using the Collection/Dictionary objects made it very easy. But now, How do i take those objects and serialize them to a JSON string? is there a library for that?
thanks you for your help.
There are quite a few JSON parser/serializer/DOM classes written in VB6. Perhaps you might want to consider one of those instead. E.g.:
JsonBag, Another JSON Parser/Generator
I am loading data from a mongodb collection to a mysql table through Kettle transformation.
First I extract them using MongodbInput and then I use json input step.
But since json input step has very low performance, I wanted to replace it with a
javacript script.
I am a beginner in Javascript and even though i tried somethings, the kettle javascript script is not recognizing any keywords.
can anyone give me sample code to convert Json data to different columns using javascript?
To solve your problem you need to see three aspects:
Reading from MongoDB
Reading from JSON
Reading from (probably) String
Reading from MongoDB Except if you changed the interface, MongoDB returns not JSON but BSON files (~binary JSON). You need to see the MongoDB documentation about reading and writing BSON: probably something like BSON.to() and BSON.from() but I don't know it by heart.
Reading from JSON Once you have your BSON in JSON format, you can read it using JSON.stringify() which returns a String.
Reading from (probably) String If you want to use the capabilities of JSON (why else would you use JSON?), you also want to use JSON.parse() which returns a JSON object.
My experience is that to send a JSON object from one step to the other, using a String is not a bad idea, i.e. at the end of a JavaScript step, you write your JSON object to a String and at the beginning of the next JavaScript step (can be further down the stream) you parse it back to JSON to work with it.
I hope this answers your question.
PS: writing JavaScript steps requires you to learn JavaScript. You don't have to be a master, but the basics are required. There is no way around it.
you could use the json input step to get the values of this json and put in common rows
I'm trying to find a more memory efficient solution for converting XML string to JSON string (and vice versa)
without using XmlDocument.
Currently, all 3rd party libraries i tried, expects XmlDocument as input.
Before I'm writing my own parser using XmlReader, i was wondering if anyone know of a out of the box solution?
What are you trying to do exactly: Generate JSON directly from XML or deserialize the XML string to an object and then serialize it to JSON?
If you need a XmlSerializer take a look into this one I created (it uses XmlReader internally), you can find the code and how to use it here:
XML serialization using Generics
I ended up writing my own thin LightXmlDocument which holds a tree of objects representing xml elements.
LoadXml method implemented using XmlReader, i'm reading the xml string and building the tree.
Tested with 10 threads each thread iterating 900 times over different xml sizes: