hhanzo1
hhanzo1

Reputation: 657

Correct JSON format in the sample

I am trying to convert this sample to json format and tried various json validators online.

The validators indicate the syntax in wrong but does not provide an example on how to resolve.

sample

 {"date": "5/8/2020", "time": "7:57:47 AM", "client": "187.45.18.205", "flags": "A", "query": "v1.addthisedge.com"}{"date": "5/8/2020", "time": "7:57:47 AM", "client": "188.35.138.205", "flags": "A", "query": "m.addthis.com"}{"date": "5/8/2020", "time": "7:57:47 AM", "client": "186.95.16.121", "flags": "A", "query": "cloud.acrobat.com"}

what is the correct json format in the sample above?

Upvotes: 0

Views: 48

Answers (3)

DevLoverUmar
DevLoverUmar

Reputation: 14011

When you try to Parse JSON, make sure your JSON objects are separeted by commas like this ...,"query": "cloud.acrobat.com"},{"date": "5/8/2020",... and the whole object is enclosed in array [{...},{...},{...}] like this

[
  {
    "date": "5/8/2020",
    "time": "7:57:47 AM",
    "client": "187.45.18.205",
    "flags": "A",
    "query": "v1.addthisedge.com"
  },
  {
    "date": "5/8/2020",
    "time": "7:57:47 AM",
    "client": "188.35.138.205",
    "flags": "A",
    "query": "m.addthis.com"
  },
  {
    "date": "5/8/2020",
    "time": "7:57:47 AM",
    "client": "186.95.16.121",
    "flags": "A",
    "query": "cloud.acrobat.com"
  }
]

Upvotes: 1

Faysal Ahmed
Faysal Ahmed

Reputation: 7669

This is the correct format of your JSON and its validated. The sample is a JSONArray object. In JSONArray each object will be separated by comma(,) and also covered with third parenthesis [] on the beginning and the end.

[
   {
      "date":"5/8/2020",
      "time":"7:57:47 AM",
      "client":"187.45.18.205",
      "flags":"A",
      "query":"v1.addthisedge.com"
   },
   {
      "date":"5/8/2020",
      "time":"7:57:47 AM",
      "client":"188.35.138.205",
      "flags":"A",
      "query":"m.addthis.com"
   },
   {
      "date":"5/8/2020",
      "time":"7:57:47 AM",
      "client":"186.95.16.121",
      "flags":"A",
      "query":"cloud.acrobat.com"
   }
]

Upvotes: 1

josgall
josgall

Reputation: 216

[{
    "date": "5/8/2020",
    "time": "7:57:47 AM",
    "client": "187.45.18.205",
    "flags": "A",
    "query": "v1.addthisedge.com"
}, {
    "date": "5/8/2020",
    "time": "7:57:47 AM",
    "client": "188.35.138.205",
    "flags": "A",
    "query": "m.addthis.com"
}, {
    "date": "5/8/2020",
    "time": "7:57:47 AM",
    "client": "186.95.16.121",
    "flags": "A",
    "query": "cloud.acrobat.com"
}]

Upvotes: 1

Related Questions