Jump to content
News about the LabVIEW Wiki! Read more... ×
Sign in to follow this  
qwerty3321

creating .json file

Recommended Posts

hello there ,

I have a normal text file .

Is there anyway to create .json file using that txt file from labview?

Share this post


Link to post
Share on other sites
3 hours ago, qwerty3321 said:

could you give me a small example please?

No.  You haven't given any information about your "normal" text file.

Share this post


Link to post
Share on other sites
14 hours ago, drjdpowell said:

No.  You haven't given any information about your "normal" text file.

just a normal simple text file to json

sample.txt

Share this post


Link to post
Share on other sites

There does not appear to be anything standard about that 'normal' file. I don't think I've ever seen such a file before.

To give you a clear picture of the complexity of what you are asking, and why drjd is quite right....just looking at that example I would assume the following about your file:

  • The entire file is a single json object
  • The first line is the 1 and only key within that object
  • there is a CRLF between the key and its value
  • The rest of the file is the value of the single key
  • The single element is itself an object
  • This object consists of key-value pairs separated by "-" and delimited by CRLF
  • Every value is a string
  • Your file cannot contain strings which contain CRLF

Following these rules, your json output would be: 

{"Details": {"Name":"abc", "Organization": "anonymous", "Location": "xyz"}}

If that is what you want, then my only answer is that you will have to procedurally parse the entire file from a string and construct the json object manually.

If that is not what you want, then you should figure out the rules for your "normal simple" file. Once you figure out the rules, you will still have to manually write the code because that isn't a standard computer-parse-able format that I am aware of.

If there are no rules, then you may need to consider a different strategy for whatever it is you are actually trying to accomplish. For example if you are making your files into json to make them easier for a computer to parse, then you'd be better of just shoving all these "normal simple" text files into elastic search or splunk and never look at them again.

Share this post


Link to post
Share on other sites

I got the output in json string after parsing .

how do i create this in .json format as output

image.thumb.png.9304e4e19f94915f4c5ccd8eecfcb321.png

Share this post


Link to post
Share on other sites

In your diagram, probe #2 is your object. You need to convert it to your specific cluster. The text you are showing is JSON format, what else do you want? .JSON files are text files.

The JSON Library I used is Labview JSON

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.