Jon Abraham
Jon Abraham

Reputation: 955

How do i remove values after comma in json

I am trying to parse below json and add values into csv file but i am having problem on how to remove values after comma. Below is my json -

 {
                  "code" : "12345",
                  "system" : "SYS1",
                  "value" : "AB345,AC1234,BC123"
     }

this is output that i am getting in csv file -

  value
 "AB345,AC1234,BC123"

but i am expecting instead -

value
"AB345"

wondering how do i remove the values after comma ?

Upvotes: 0

Views: 98

Answers (1)

M. Abreu
M. Abreu

Reputation: 366

Use split method with delimiter "," and get zeroth index of the array.

s = "AB345,AC1234,BC123".split(",", 1)[0]

Upvotes: 2

Related Questions