Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get JSON objects value if its name contains dots?

People also ask

Can JSON key contain dot?

It's impossible to use a literal dot in a JSON key with FileMaker's JSON parsing functions.

How can I get the index from a JSON object with value?

To get the index from a JSON object with value with JavaScript, we can use the array findIndex method.

How do I access JSON data?

To access the JSON object in JavaScript, parse it with JSON. parse() , and access it via “.” or “[]”.

Can JSON contain objects?

JSON SyntaxJSON defines only two data structures: objects and arrays. An object is a set of name-value pairs, and an array is a list of values. JSON defines seven value types: string, number, object, array, true, false, and null.


What you want is:

var smth = mydata.list[0]["points.bean.pointsBase"][0].time;

In JavaScript, any field you can access using the . operator, you can access using [] with a string version of the field name.


in javascript, object properties can be accessed with . operator or with associative array indexing using []. ie. object.property is equivalent to object["property"]

this should do the trick

var smth = mydata.list[0]["points.bean.pointsBase"][0].time;

Try ["points.bean.pointsBase"]


If json object key/name contains dot......! like

var myJson = {"my.name":"vikas","my.age":27}

Than you can access like

myJson["my.name"]
myJson["my.age"]