/    Sign up×
Community /Pin to ProfileBookmark

Integer in object tree ???

Hey all!
Ok I have JS object w/ following structure:

[code=php]json_data_object.422.name[/code]

thta should of out put me “hello world” as it is what it is in array but it does not as there is 422 there ?
That’s my ID from database, and I gotta use it

Now, if I change that ID to something in letters say to “i” then everything is fine. ex

[code=php]json_data_object.i.name[/code]

That one would work, but then I have to chnge JSON string thta pulls data from DB and i cant really do that…

[B]So the question is how can I make 422 (numbers) works the same way as just string values in the array/object tree?
[/B]

hope some one can help!
tnx!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JonaOct 16.2010 — [font=arial]Hi,

Reference it as an associative array.[/font]

<i>
</i>json_data_object['422'].name
Copy linkTweet thisAlerts:
@alexusauthorOct 16.2010 — that didnt work ?

Getting this error on Mozila Error Coonsole:


Error: missing name after . operator

Source File: file:json.html

Line: 25, Column: 35

Source Code:

alert(json_data_object.['422'].name); [/QUOTE]


what esle can i try?
Copy linkTweet thisAlerts:
@alexusauthorOct 16.2010 — ups ?

i always been terribly unatentive to details ?

json_data_object['422'].name

this works perfectly ?

Thank you!
Copy linkTweet thisAlerts:
@JonaOct 17.2010 — [font=arial]Happy to help![/font]
×

Success!

Help @alexus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...