0

I have a problem, what I'm trying to do is just parse some values from JSON using batch...

I'm obtaining a JSON file by calling:

curl -G http://xxxxxx.xx/xx/xx

That calling returns a string which is 25 000 characters long, the valuse are "key":"value" separated by ,. I was trying to separate it by using for with delimeters but it doesn't work because that string is too long for storage in memory...

I really don't know how can I do that and if it's possible... Anybody any ideas?

Thanks

EDIT: json file looks like: json pastebin but it`s without whitespaces....

1
  • 1
    Please show your json file, you can upload a part to eg. pastebin. Commented Jul 19, 2013 at 14:59

1 Answer 1

1

Normally any line in a batch file can't exceed 8192 characters.
Only FOR /F can read any line from a file, but still you can't assign parameters longer than 8191bytes.

But if you split it in a way, so that each single parameter is smaller, then it works.
Even if you know that the thrid parameter is longer, then you simply can ignore it.

FOR /F "token=1-10 delims=," %%a in (longFile.txt) do (
  echo %%a
  echo %%b

  echo %%d
)
Sign up to request clarification or add additional context in comments.

3 Comments

+1, Very cool. I had no idea this was possible. Though I'm not sure it will help the OP. The values may not always be in the same order. And FOR /F cannot parse more than 32 values in one pass. If there are more than 32 values and the length after 31 is more than 8192, then it seems this is doomed to failure.
Ok it looks like it can work, but the problem is, that in the response are not lines... everything is in one line so I need something what will say that what are delims for a newline
You could try to use { or } as a delim, but batch isn't the right language for this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.