-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to process array of struct #107
Comments
Actually I want to process the following struct [ |
Hey @ArulJeyananth, thanks for submitting this issue! Your initial JSON sample seems to be invalid JSON, since you're using package main
import (
"github.com/Jeffail/gabs/v2"
)
func main() {
data := []byte(`[
{"foo":"test1"},
{"foo":"test2"}
]`)
g, _ := gabs.ParseJSON(data)
println(g.Path("0.foo").String())
println(g.Path("1.foo").String())
data = []byte(`[
{
"addressLine1": "5500 Grand Lake Dr",
"city": "San Antonio",
"state": "TX",
"zipCode": "78244",
"formattedAddress": "5500 Grand Lake Dr, San Antonio, TX 78244",
"assessorID": "05076-103-0500",
"bedrooms": 3,
"county": "Bexar",
"legalDescription": "CB 5076A BLK 3 LOT 50",
"squareFootage": 1878,
"subdivision": "CONV A/S CODE",
"yearBuilt": 1973,
"bathrooms": 2,
"lotSize": 8843,
"propertyType": "Single Family",
"lastSaleDate": "2017-10-19T00:00:00.000Z",
"features": {
"architectureType": "Contemporary",
"cooling": true,
"coolingType": "Central",
"exteriorType": "Wood",
"floorCount": 1,
"foundationType": "Slab",
"garage": true,
"garageType": "Garage",
"heating": true,
"heatingType": "Forced Air",
"pool": true,
"roofType": "Asphalt",
"roomCount": 5,
"unitCount": 1
},
"taxAssessment": {
"2018": {
"value": 126510,
"land": 18760,
"improvements": 107750
},
"2019": {
"value": 135430,
"land": 23450,
"improvements": 111980
},
"2020": {
"value": 142610,
"land": 23450,
"improvements": 119160
}
},
"propertyTaxes": {
"2019": {
"total": 2997
}
},
"owner": {
"names": [
"MICHEAL ONEALSMITH"
],
"mailingAddress": {
"id": "5731-Pool-Canyon-Cv,-Austin,-TX-78734",
"addressLine1": "5731 Pool CanyonCv",
"city": "Austin",
"state": "TX",
"zipCode": "78734"
}
},
"id": "5500-Grand-Lake-Dr,-San-Antonio,-TX-78244",
"longitude": -98.351442,
"latitude": 29.475962
}
]`)
g, _ = gabs.ParseJSON(data)
println(g.Path("0.id").String())
} It prints:
|
Hi there, Thank you for the answer and the great package. I wanted to ask briefly whether there might be an issue with the function call.
Result is |
@henninggaus It looks like you imported |
Hi @henninggaus . I encountered the same issue, and it is resolved by the suggestion of #107 (comment) .
|
[
{"foo":"test1"},
{"foo":"test2"}
}
Suppose i have a JSON structure as above. I tried to get the value as
"0.foo" as jsonParsed.Path("0.foo").String()
and
"1.foo" as as jsonParsed.Path("1.foo").String()
It is not giving any value for this. Gives value as {}
The text was updated successfully, but these errors were encountered: