0

I don't have json package.And I create json object and want print it.Is there any way to do this by js native function? Or I should write this function by myself?

P.S. I can't import any additional files.And I use Js in program not in browser. JSON is not defined.

Thanks!

1

1 Answer 1

1

add js script

<script src="https://github.com/douglascrockford/JSON-js/json2.js" />

alert json object

var obj = {
    a : 10,
    b : 20,
    c : {d: "foo", e: "bar"}
};
alert(JSON.stringify(obj))
Sign up to request clarification or add additional context in comments.

2 Comments

Script tag require closing tag + that url goes to a 404.
... further the raw version is MIME type ('text/plain') – which will exclude it from execution when strict MIME type checking is enabled. It is not compressed, not intended for direct linking, etc. Check out cdnjs.com or similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.