M
M
Mikhail Dudkin2016-08-04 12:43:08
Python
Mikhail Dudkin, 2016-08-04 12:43:08

How to parse a javascript object and convert it to json?

Is there an easy way to convert a string with a js object to json, or a list of python objects.

var sections = new Verba.Compare.Collections.Sections([{
    "id": "121345",
    "title": "AAA HEBR 111",
    "catalog_id": null,
    "continuation": null,
    "name": "400",
    "instructor": null,
    "notes": null,
    "insite_url": null,
    "no_books_text": "Currently Awaiting Course Materials Requisition",
    "no_books_link": null,
    "compare_items": [{
        "id": null,
        "isbn": "9781584654599",
        "title": "Brandeis Modern Hebrew (W/Cd Only)",
        "author": "Ringvald",
        "created_at": null,
        "updated_at": null,
        "user_id": 39,    
    }],
    "books": [{
        "id": "121345_9781584654599_0",
        "isbn": "9781584654599",
        "pf_id": null,
        "new_item_id": "new_18916003",
        "used_item_id": "used_18916003",
        "required": "Required",
        "sort_order": ["0", "1", "Brandeis Modern Hebrew (W/Cd Only)"],
        "cover_image_url": "//coverimages.verbacompete.com/ebc23a47-7e57-5048-95a9-f4f46c35f344.jpg",
        "title": "Brandeis Modern Hebrew (W/Cd Only)",
        "author": "Ringvald",
        "notes": null,
        "citation": "\u003Cem\u003EBrandeis Modern Hebrew (W/Cd Only)\u003C/em\u003E by Ringvald. University Press Of New England, 2005. (ISBN: 9781584654599).",
        "metadata": ["18916003", "18916010", "105", "205", "290347", "121345", "True"],        
        "section_id": "121345",
        "db_section_id": null,
        "inclusive_access": false,
        "catalog_id": null,
        "edition": null,
        "copyright_year": "2005"
    }]
}]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hetzerok, 2016-08-04
@hetzerok

Well, in js, JSON.stringify() is done, and in python, json.loads().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question