Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-13-2011, 04:49 AM   PM User | #1
json767
New to the CF scene

 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
json767 is an unknown quantity at this point
Parsing JSON for a SQL table

This fake link http://example.json.com/color.json brings back the JSON content below.

{ "one" : true,
"three" : [ "red",
"yellow",
[ "blue",
"azure",
"cobalt",
"teal"
],
"orange"
],
"two" : 19.5
}

I need to load this data to a SQL table. Here is my thought for changing it to a table structure.

identity_id|model|level|linked_id|position|name|value|data_type
1|color|1||1|one|true|boolean
2|color|1||2|three||reference
3|color|2|2|1|three|red|string
4|color|2|2|2|three|yellow|string
5|color|2|2|3|three||reference
6|color|3|5|1|three|blue|string
7|color|3|5|2|three|azure|string
8|color|3|5|3|three|cobalt|string
9|color|3|5|4|three|teal|string
10|color|2|2|4|three|orange|string
11|color|1||3|two|19.5|decimal

legend:
model = JSON URI; I want to combine data for multiple URIs.
level = the depth of the data in the structure
linked_id = reference the identity_id where the level>1
position = the order of the field
name = data name
value = data value
data_type = string, date, number, boolean, reference (place holder for linked row)

I can query this table to populate other tables. Any one has a better idea? Here is an exercise. Write a program to convert the JSON to the table format above.
json767 is offline   Reply With Quote
Reply

Bookmarks

Tags
format, json, parse, sql, table

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:02 PM.


Advertisement
Log in to turn off these ads.