2 Replies Latest reply: May 27, 2014 2:19 PM by jschellSomeoneStoleMyAlias RSS

    How to format(parse) json file ?

    user8729783

      Hi All,

       

       

      I have written my program result into a json file but i am getting json file in below format.

       

      {"one":"one","two":"two","three":"three"}

       

      but I have lot of entries to write into json finally it become unreadle format which is not very compart to read.

       

      Is there any way to format or writing line by line into json file like below format,

       

      {

      "one":"one",

      "two":"two",

      "three":"three"

      }

       

      Could any body please help me to resolve this issue asap.

       

       

      Thanks In Advance.

        • 1. Re: How to format(parse) json file ?
          rp0428

          Could any body please help me to resolve this issue asap.

          No - there is no such thing as 'asap' in the forums. If you need help 'asap' you need to hire a consultant.

           

          I have written my program result into a json file but i am getting json file in below format.

           

          {"one":"one","two":"two","three":"three"}

           

          but I have lot of entries to write into json finally it become unreadle format which is not very compart to read.

           

          Is there any way to format or writing line by line into json file like below format,

           

          {

          "one":"one",

          "two":"two",

          "three":"three"

          }

           

          Well - YOU are the one writing the file so YOU can write it in whatever format you want to use. Both of those formats can be easily read by a simple program and the first format is MORE compact than the second.

           

          Just add a 'newline' character after every entry. You haven't posted any code so we have no way of knowing how you are writing the file now.

          • 2. Re: How to format(parse) json file ?
            jschellSomeoneStoleMyAlias

            Depends on how you wrote it.

            As noted if you are writing it yourself then you would need to change your output.

            Conversely if you are using a library to serialize your object into JSON then it probably has a 'pretty print' method.